{% extends "reviews/reviewable_base.html" %}
{% load difftags djblets_deco djblets_js djblets_utils i18n rb_extensions reviewtags %}
{% load staticfiles tz %}

{% block title %}{{review_request_details.summary}} | {% trans "Diff Viewer" %}{% endblock %}

{% block css %}
{{block.super}}

{%  if siteconfig_settings.diffviewer_show_trailing_whitespace %}
<style type="text/css">
  #diffs.ewhl table.sidebyside .ew { background: #ee3434; }
</style>
{%  endif %}
{% endblock css %}

{% block content %}
{%  if error %}
{%   errorbox %}
<p>{{error}}</p>
{%    if trace %}<pre>{{trace|escape}}</pre>{% endif %}
{%   enderrorbox %}
{%  else %}{# !error #}

<div id="review_request">
{% display_review_request_trophies review_request %}
{%   include "reviews/review_header.html" %}

{%   box "review-request" %}
 <div class="review-request-header">
  <ul class="actions page-tabs">
   <li><a href="{{review_request.get_absolute_url}}">{% trans "Reviews" %}</a></li>
   <li class="active"><a href="{% url 'view-diff' review_request.display_id %}#index_header">{% trans "Diff" %}</a></li>
  </ul>

  <div class="actions-container">
   {% star review_request %}
   <ul class="actions actions-right-container">
    <li class="has-menu">
     <a href="#" class="mobile-actions-menu-label"><span class="fa fa-ellipsis-h fa-lg"></span></a>
     <ul class="actions actions-right">
{%    include "reviews/review_request_actions_secondary.html" %}
{%    diffviewer_action_hooks %}
      <li id="download-diff" {% if interdiffset %}style="display: none;"{% endif %}><a href="raw/">{% trans "Download Diff" %}</a></li>
{%    include "reviews/review_request_actions_primary.html" %}
     </ul>
    </li>
   </ul>
  </div>
 </div>

<div class="main">
{%    include "reviews/review_request_box.html" %}

<div id="diff-details" class="content loading">
 <a name="index_header"></a>
 <div id="diff_revision_label"></div>
  <div id="diff_revision_selector"></div>
  <div id="diff_comments_hint"></div>
  <div id="diff_index">
   <span class="fa fa-spinner fa-pulse"></span>
  </div>
  <div id="pagination1"></div>
 </div>
</div>
{%   endbox %}

<ul id="view_controls">
{%    if collapseall %}
 <li><a href=".?expand=1"><span class="fa fa-plus"></span> {% trans "Expand changes" %}</a></li>
{%    else %}
 <li><a href=".?collapse=1"><span class="fa fa-minus"></span> {% trans "Collapse changes" %}</a></li>
{%    endif %}
{%    if siteconfig_settings.diffviewer_show_trailing_whitespace %}
 <li class="ew" style="display:none;"><a href="#" class="toggle-show-whitespace"><span class="fa fa-minus"></span> {% trans "Hide extra whitespace" %}</a></li>
 <li class="ew"><a href="#" class="toggle-show-whitespace"><span class="fa fa-plus"></span> {% trans "Show extra whitespace" %}</a></li>
{%    endif %}
 <li class="ws"><a href="#" class="toggle-whitespace-only-chunks"><span class="fa fa-minus"></span> {% trans "Hide whitespace changes" %}</a></li>
 <li  class="ws" style="display:none;"><a href="#" class="toggle-whitespace-only-chunks"><span class="fa fa-plus"></span> {% trans "Show whitespace changes" %}</a></li>
</ul>

<div id="diffs"></div>
<div id="pagination2"></div>

{%  endif %}{# !error #}
{% endblock content %}

{% block scripts-post %}
{{block.super}}

<script>
    RB.PageManager.setPage(new RB.DiffViewerPageView({
        model: new RB.DiffViewerPageModel({{diff_context|json_dumps}},
                                          {parse: true}),
        checkUpdatesType: 'diff',
{%  localtime off %}
        lastActivityTimestamp: {{last_activity_time|json_dumps}},
{%  endlocaltime %}
{%  include "reviews/reviewable_page_data.js" %}
    }));
</script>
{% endblock scripts-post %}
